#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<assert.h>

using namespace std;


class Date
{
public:
	Date(int year = 1, int month = 1, int day = 1)
	{
		_year = year;
		_month = month;
		_day = day;
	}

	void Print()
	{
		cout << _year << "/" << _month << "/" << _day << endl;
	}

	//int GetYear();

	bool operator==(const Date& y)
	{
		return _year == y._year
			&& _month == y._month
			&& _day == y._day;
	}

	bool operator>(const Date& y)
	{
		if (_year > y._year)
		{
			return true;
		}
		else if (_year == y._year && _month > y._month)
		{
			return true;
		}
		else if (_year == y._year && _month == y._month && _day > y._day)
		{
			return true;
		}
		return false;
	}

	int GetMonthDay(int year, int month)
	{
		//assert(year >= 1 && month >= 1 && month <= 12);
		int arrDay[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
		if (month == 2 && ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0)))
		{
			return 29;
		}
		return arrDay[month];

	}

	Date& operator= (const Date & y)
	{
		if (this != &y)
		{
			_year = y._year;
			_month = y._month;
			_day = y._day;
		}
		return *this;
	}
	/*Date& operator+= (int day)
	{
		_day += day;
		while (_day > GetMonthDay(_year, _month))
		{
		
			_day -= GetMonthDay(_year, _month);

			_month++;
			if (_month == 13)
			{
				_year++;
				_month = 1;
			}
		}
		return *this;
	}*/

	/*Date operator+ (int day)
	{
		Date tmp(*this);

		tmp += day;

		return tmp;
	}*/

	Date operator+ (int day)
	{
		Date tmp(*this);

		tmp._day += day;
		while (tmp._day > GetMonthDay(tmp._year, tmp._month))
		{

			tmp._day -= GetMonthDay(tmp._year, tmp._month);

			tmp._month++;
			if (tmp._month == 13)
			{
				tmp._year++;
				tmp._month = 1;
			}
		}
		return tmp;
	}
	Date& operator+=(int day)
	{
		*this = *this + day;
		return *this;
	}

private:
	int _year;
	int _month;
	int _day;
};
int main()
{
	Date d1(2023,10,24);
	Date d2;

	cout << (d1 > d2) << endl;
	//d1 += 100;
	//d2 = d1 + 100;
	

	d2 = d1;
	d1.Print();
	d2.Print();

	return 0;
}